package com.example.research.controller;

import com.example.research.dto.ApiResponse;
import com.example.research.service.DashboardService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.core.Authentication;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

@RestController
@RequestMapping("/dashboard")
public class DashboardController {

    @Autowired
    private DashboardService dashboardService;

    @GetMapping("/stats")
    public ApiResponse<Map<String, Object>> getStats(Authentication authentication) {
        String username = authentication.getName();
        Map<String, Object> stats = dashboardService.getStats(username);
        return ApiResponse.success(stats);
    }

    @GetMapping("/recent-items")
    public ApiResponse<Map<String, Object>> getRecentItems(Authentication authentication) {
        String username = authentication.getName();
        Map<String, Object> recentItems = dashboardService.getRecentItems(username);
        return ApiResponse.success(recentItems);
    }
}
